package com.bdqn.boot.yuanshen.service.impl;

import com.bdqn.boot.yuanshen.bean.Interaction;
import com.bdqn.boot.yuanshen.mapper.InteractionMapper;
import com.bdqn.boot.yuanshen.service.InteractionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zwt
 * @version 1.0
 * @className InteractionServiceImpl
 * @description 用户互动服务实现类
 * @date 2025/3/12 09:53
 */
@Service
public class InteractionServiceImpl implements InteractionService {

    @Autowired
    private InteractionMapper interactionMapper;

    @Override
    public PageInfo<Interaction> getInteractions(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Interaction> interactions = interactionMapper.selectAll();
        return new PageInfo<>(interactions);
    }

    @Override
    public Interaction getById(Integer id) {
        return interactionMapper.getById(id);
    }

    @Override
    public void addInteraction(Interaction interaction) {
        interactionMapper.insert(interaction);
    }

    @Override
    public void updateInteraction(Interaction interaction) {
        interactionMapper.update(interaction);
    }

    @Override
    public void deleteInteraction(Integer id) {
        interactionMapper.del(id);
    }
}